*This file combines raw data files, cleans variables, and creates the final analysis data file.

********************************************************************************
* make a combined data file 
********************************************************************************

* Import data from hypothesis and study spreadsheets
	* NORC 
		import excel ../Metadata/1a_Studies_NORC.xlsx, sheet("Studies") firstrow clear
		tempfile Studies_NORC	
		sa `Studies_NORC'

		import excel ../Metadata/1b_Hypotheses_NORC.xlsx, sheet("Hypotheses") firstrow clear
		tempfile Hypotheses_NORC	
		sa `Hypotheses_NORC'

	* KN 
		import excel ../Metadata/2a_Studies_KN.xlsx, sheet("Studies") firstrow clear
		tempfile Studies_KN	
		sa `Studies_KN'

		import excel ../Metadata/2b_Hypotheses_KN.xlsx, sheet("Hypotheses") firstrow clear
		tempfile Hypotheses_KN
		sa `Hypotheses_KN'


* Append study files
		use `Studies_KN', clear
		append using `Studies_NORC'

		tempfile allstudies
		sa `allstudies'


* Append hypothesis files
		use `Hypotheses_KN', clear
		append using `Hypotheses_NORC'

		cap drop checked_date

		tempfile allhypotheses
		sa `allhypotheses'


* merge hypothesis and studies files
		use `allstudies', clear
		merge 1:m PI vendor_id using `allhypotheses'

		* exclude out of sample studies
			drop if sample=="no"

		* total number of unique studies
			tab sample if hyp_num==1 // 100 studies

		* total hypotheses
			tab sample // 1102
			tab _merge

	
* create an indicator "study" (=PIname+study id) to merge results files
		split PI, gen(name)
		drop name1
		replace name2=name3 if name3!= ""
		drop name3
		egen str study=concat(name2 proposal_id)
		drop name2
		
		* replace Harbridge-Yong to remove hyphen
		replace study = "HarbridgeYong1032" if study=="Harbridge-Yong1032"	


* Merge hypothesis test results
		cap drop _merge
		merge 1:1 study hyp_num using ../Metadata/Hypotheses_results.dta 
		tab _merge


********************************************************************************
* VARIABLES
********************************************************************************
* STUDY INFO

* was this a short study? (marked by prefixes S and B in NORC & KN proposal IDs, respectively)
	gen shortstudy = 1 if regexm(proposal_id, "B")
	replace shortstudy=1 if regexm(proposal_id, "S")
	replace shortstudy=0 if shortstudy!=1
	
	tab shortstudy if hyp_num==1 // 27 short studies
	
	lab var shortstudy "Short study"
	
* study id number
	lab var vendor_id "study ID #"

* study variable used for merge with results	
	lab var study "PI last name+proposal id"
	
* vendor
	split vendor_id, parse(K) generate(temp)
	gen vendor="1" if temp1==""
	replace vendor="2" if temp2==""
	destring vendor, replace
	lab def vendor 1 "1 Knowledge Networks" 2 "2 NORC"
	lab val vendor vendor
	drop temp*
	tab vendor if hyp_num==1

* date data delivered
	tab date_delivered

	* year	
	gen year=year(date_delivered)
	tab year

	* month
	gen month=month(date_delivered)
	tab month

* sample size
	tab samplesize if hyp_num==1	
	lab var samplesize "Sample size"
	
********************************************************************************
* PI DEMOGRAPHICS

* PI's primary discipline
	tab discipline
	lab def discipline ///
	1 "1 Business" ///
	2 "2 Communication" ///
	3 "3 Economics" ///
	4 "4 Health policy" ///
	5 "5 Political Sci." ///
	6 "6 Psychology"  ///
	7 "7 Public health" ///
	8 "8 Public policy" ///
	9 "9 Social policy" ///
	10 "10 Social psychology" ///
	11 "11 Sociology" ///
	12 "12 Survey methodology" 

	replace discipline="1" if discipline=="Business"
	replace discipline="2" if discipline== "Communication"
	replace discipline="3" if discipline== "Economics"
	replace discipline="4" if discipline== "Health policy"
	replace discipline="5" if discipline== "Political science"
	replace discipline="6" if discipline== "Psychology"
	replace discipline="7" if discipline== "Public health"
	replace discipline="8" if discipline== "Public policy"
	replace discipline="9" if discipline== "Social policy"
	replace discipline="10" if discipline== "Social psychology"
	replace discipline="11" if discipline== "Sociology"
	replace discipline="12" if discipline=="Survey methodology"

	destring discipline, replace
	lab val discipline discipline
	tab discipline if hyp_num==1

* discipline, collapsed
	lab def disciplinecoll ///
	1 "Political science" ///
	2 "Sociology" ///	
	3 "Psychology"  ///
	4 "Policy studies" ///
	5 "Other discipline"

	recode discipline (5=1) (11=2) (6=3) (10=3) (4=4) (7/9=4) (1=5) (3=5) (2=5) (12=5), gen(discipline_collapse)
	lab val discipline_collapse disciplinecoll
	tab discipline_collapse if hyp_num==1
	lab var discipline_collapse "PI Discipline"
	
* gender
	tab woman if hyp_num==1
	lab var woman "Woman PI"
	lab def woman 1 "Woman PI" 0 "Man PI"
	lab val woman woman
	
* title
	lab def title ///
	1 "Graduate student" ///
	2 "Post-doc" ///
	3 "Assistant prof." ///
	4 "Associate prof." ///
	5 "Professor" ///
	6 "Other title"  
	
	replace title = "1" if title=="grad student"
	replace title = "2" if title=="postdoc"
	replace title = "3" if title=="assistant professor"
	replace title = "4" if title=="associate professor"
	replace title = "5" if title=="professor"
	replace title = "6" if title=="other"
	destring title, replace
	lab val title title
	tab title if hyp_num==1
	lab var title "PI title"
	
	recode title (1=0) (2/5=1) (6=.), gen(hasphd)
	tab hasphd if hyp_num==1 // 63% have phd degrees
	lab var hasphd "PI has a doctorate"
	
	recode title (1/3=1) (6=.) (4/5=0), gen(earlycareer)
	tab earlycareer if hyp_num==1 // 77% early career
	lab var earlycareer "Early career PI"
	
********************************************************************************
* STUDY CHARACTERISTICS

* number of investigators
	tab numauthors
	lab var numauthors "Number of investigators"
	recode numauthors (1=1 "1 investigator") (2=2 "2 investigators") (3/4=3 "3+ investigators"), gen(numauthorscat)
	lab var numauthorscat "No. of investigators"
	
* any attention or manipulation checks

	replace any_checks="1" if any_checks=="yes"
	replace any_checks="0" if any_checks=="no"
	destring any_checks, replace

	lab var any_checks "Any checks"
	lab def any_checks 1 "Any checks" 0 "No checks"
	lab val any_checks any_checks
	
	tab any_checks if hyp_num==1

* type of check	
	tab check_type
	lab def checktype 0 "No checks" 1 "Attention/Comprehension" 2 "Manipulation"
	replace check_type = "0" if any_checks==0
	replace check_type = "1" if check_type== "attention"
	replace check_type = "1" if check_type== "comprehension"
	replace check_type = "2" if check_type== "manipulation"
	destring check_type, replace
	lab val check_type checktype
	tab check_type
	
* pilot study was conducted

	lab var pilot_original "pilot mentioned in original proposal"
	lab var pilot_revised "pilot mentioned in revised proposal"

	replace pilot_original="1" if pilot_original=="yes"
	replace pilot_original="0" if pilot_original=="no"
	replace pilot_revised="1" if pilot_revised=="yes"
	replace pilot_revised="0" if pilot_revised=="n/a"
	replace pilot_revised="0" if pilot_revised==""	
	destring pilot_original pilot_revised, replace

	tab pilot_original if hyp_num==1
	tab pilot_revised if hyp_num==1

	gen pilot =pilot_original
	replace pilot=1 if pilot_revised==1
	lab var pilot "Pilot conducted"
	tab pilot if hyp_num==1, mis // 74% of cases
	lab def pilot 1 "Pilot included" 0 "No pilot"
	lab val pilot pilot
	
* clarity of proposal	
	split howeasy, parse([) generate(temp)
	tab temp1
	gen clarity = temp1 
	destring clarity, replace
	lab var clarity "Clarity of proposal (1-5)"
	drop temp*
	tab clarity, mis
	
	recode clarity (1/2=1 "Clarity 1-2") (3=2 "Clarity 3") (4=3 "Clarity 4") (5=4 "Clarity 5"), gen(claritycat)
	lab var claritycat "Clarity"
	
* median time taken to complete study
	tab medtime
	// divide by total number of studies (to adjust for co-fielded studies)
	gen medtime_adjusted= medtime/num_cofielded
	lab var medtime_adjusted "Median duration (mins.)"
	
	* recode outliers (>15 minutes)
	gen medtime15=medtime_adjusted
	replace medtime15=15 if medtime_adjusted>=15
	lab var medtime15 "Median duration (mins.)"
	
	
* experiment type (non-exclusive categories)
		foreach var of varlist type_* {
			tab `var'
			replace `var'=0 if `var'==.
			tab `var'
		}

		lab var type_conjoint "Conjoint experiment"
		lab var type_discretechoice "Discrete choice experiment"		
		
		gen type_conj_dce=type_conjoint
		replace type_conj_dce= type_discretechoice if type_discretechoice==1
		
		lab var type_framing "Framing experiment"
		lab var type_priming "Priming experiment"
		lab var type_vignette "Vignette experiment"
		lab var type_questwording "Question-wording experiment"
		lab var type_information "Information provision experiment"
		lab var type_beliefelicit "Belief elicitation experiment"
		lab var type_writing "Writing treatment"
		lab var type_conj_dce "Conjoint/Discrete choice experiment"

	
		* experiments with more than one category
		gen type_count=type_framing +type_priming +type_vignette +type_questwording ///
		+type_information +type_beliefelicit +type_conj_dce+ type_writing
		tab type_count if hyp_num==1 // 6 experiments have more than one type
		
		drop type
		lab def type_study 1 "Framing" 2 "Priming" 3 "Vignette" 4 "Question-wording" 5 "Information provision" 6 "Belief elicitation" 7 "Conjoint/DCE" 8 "Writing+Fram./Prim." 9 "Other"
		gen type_study=.
		replace type_study=1 if type_framing==1 & type_count==1
		replace type_study=2 if type_priming==1& type_count==1	
		replace type_study=3 if type_vignette==1& type_count==1
		replace type_study=3 if type_vignette==1& type_count==2 // this is the Beaulieu study		
		replace type_study=4 if type_questwording==1& type_count==1
		replace type_study=5 if type_information==1& type_count==1
		replace type_study=6 if type_beliefelicit==1& type_count==1
		replace type_study=7 if type_conj_dce==1& type_count==1
		replace type_study=8 if type_writing==1	
		replace type_study=8 if type_writing==1			
		lab val type_study type_study 
		tab type_study if hyp_num==1
		
		lab var type_study "Experiment type"
		
* was the study published		
	gen published_binary=.
	replace published_binary=1 if ///
	published=="book" | ///
	published=="book chapter" | ///
	published=="conference activity < 30mos" | ///
	published=="conference activity > 30mos" | ///
	published=="journal article" | ///	
	published=="methodological report" | ///
	published=="preprint <30mos" | ///
	published=="preprint >30mos" | ///
	published=="maybe: book" | ///
	published=="maybe: journal article" 
	
	replace published_binary=0 if ///
	published=="dissertation" | ///
	published=="masters thesis" | ///	
	published=="no leads" | ///	
	published=="non-conference presentation" 
	
	tab published_binary if hyp_num==1, mis 
	lab var published_binary "Any publication or conference activity"
	
* multiple obs per person
	gen panel=1 if reshaped=="yes"
	replace panel=0 if reshaped==""
	lab var panel "Multiple obs./person"

********************************************************************************
* HYPOTHESIS TESTS

* total number of hypotheses in the study
	egen total_hyp=max(hyp_num), by(vendor_id)
	lab var total_hyp "Total hypotheses in study"

* hypothesis was supported
	tab hyp_true 
	tab vendor hyp_true
	lab var hyp_true "Hypothesis supported"

* at least one hypothesis was supported in the study
	egen hyp_anytrue=max(hyp_true), by(vendor_id)
	tab hyp_anytrue if hyp_num==1
	lab var hyp_anytrue "At least 1 hypothesis supported"

	sort vendor_id
	br vendor_id PI if hyp_num==1 & hyp_anytrue==1
	br vendor_id PI if hyp_num==1 & hyp_anytrue==0

* at least 5% of hypotheses supported 
	// total hypotheses supported 
	egen total_hyp_true=sum(hyp_true), by(vendor_id)
	// what is 5% of total hypotheses
	gen temp=total_hyp*0.05
	gen hyp_5pct_supported=1 if total_hyp_true>=temp & total_hyp_true!=.
	replace hyp_5pct_supported=0 if total_hyp_true<temp & temp!=.
	drop temp
	sum hyp_5pct_supported
	lab var hyp_5pct_supported "At least 5% hypotheses supported"

* at least 10% of hypotheses supported 
	// what is 10% of total hypotheses
	gen temp=total_hyp*0.1
	gen hyp_10pct_supported=1 if total_hyp_true>=temp & total_hyp_true!=.
	replace hyp_10pct_supported=0 if total_hyp_true<temp & temp!=.
	drop temp
	sum hyp_10pct_supported
	lab var hyp_10pct_supported "At least 10% hypotheses supported"	
	
* successful experiment (at least 1 hyp true if #hyp<=10; or 10% hyp true if #hyp>20)	
	gen successfulexp=hyp_anytrue if total_hyp<=10
	replace successfulexp=hyp_10pct_supported if total_hyp>10
	tab successfulexp
	lab var successfulexp "Successful study"
	
	
********************************************************************************	
		
* hypothesis p-value significant, but in the wrong direction
	split pvalue, parse(_) generate(var)
	replace pvalue=var1
	drop var1
	destring pvalue, replace
	tab pvalue

	rename var2 wrongsign
	replace wrongsign="1" if wrongsign=="W"
	replace wrongsign="0" if wrongsign==""
	destring wrongsign, replace 
	tab wrongsign
	lab var wrongsign "P-value sig.; wrong sign"	

********************************************************************************
* HYPOTHESIS CHARACTERISTICS

* estimation sample size
	lab var N_person "Sample size"
	
* bonferroni correction used	
	lab var bonf "Bonferroni correction factor"
	
* non-treatment hypothesis
	tab non_treatment_test
	replace non_treatment_test= "1" if non_treatment_test=="yes"
	replace non_treatment_test= "0" if non_treatment_test=="no"
	destring non_treatment_test, replace
	tab non_treatment_test, mis
	lab var non_treatment_test "Non-treatment test"
	
* hypothesis entailed moderation analysis	
	replace moderation = "1" if moderation =="yes"
	replace moderation = "0" if moderation=="no"
	destring moderation, replace
	tab moderation, mis	
	lab var moderation "Moderation test"
	
	replace is_int = "1" if is_int =="yes"
	replace is_int = "0" if is_int=="no"
	destring is_int, replace
	tab is_int, mis	
	// note: this variable has missing data for non-regression tests 
	
* hypothesis entailed mediation analysis	
	replace mediation = "1" if mediation =="yes"
	replace mediation = "0" if mediation=="no"
	destring mediation, replace
	tab mediation, mis	
	lab var mediation "Mediation test"
	
	* study had any mediation analyses
	egen mediation_instudy=max(mediation), by(vendor_id)
	lab var mediation_instudy "Mediation analyses, any"
	
* test was conducted on a sub-sample
	replace subsample = "1" if subsample =="yes"
	replace subsample = "0" if subsample =="no"
	destring subsample, replace
	tab subsample, mis

	lab var hyp_nodiff "No-difference test"
	replace hyp_nodiff=0 if hyp_nodiff==.	
	
* t-test
	gen hyp_t=1 if typeoftest=="ttest"
	replace hyp_t=0 if typeoftest!="ttest"
	lab var hyp_t "One sample t-test"

* ks-test	
	gen hyp_ks=1 if typeoftest=="ksmirnov"
	replace hyp_ks=0 if typeoftest!="ksmirnov"
	lab var hyp_ks "K-Smirnov test"

* default test of treatment comparison, excluding all other categories	
	gen hyp_default=1 if typeoftest=="default"
	replace hyp_default=0 if typeoftest!="default"
	lab var hyp_default "Default treatment comparison"	
	replace hyp_default=0 if moderation==1 |hyp_nodiff==1|non_treatment_test==1
	tab hyp_default
	
	
* categorical variable summarizing hypothesis type
	lab def hyptype 1 "Default treatment comparison" 2 "Moderation" 3 "Mediation" 4 "t-test" 5 "K-Smirnov test" 6 "Non-treatment test" 7 "No difference test"	
	gen hyp_type=.
	replace hyp_type=1 if hyp_default==1
	replace hyp_type=2 if moderation==1
	replace hyp_type=3 if mediation==1
	replace hyp_type=4 if hyp_t==1
	replace hyp_type=5 if hyp_ks==1
	replace hyp_type=6 if non_treatment_test==1	
	replace hyp_type=7 if hyp_nodiff==1
	lab val hyp_type hyptype
	tab hyp_type
	
	
	// note the combined categorical variable is not useful because some categories overlap
	tab hyp_type hyp_default, mis	
	tab hyp_type moderation, mis
	tab hyp_type mediation, mis	
	tab hyp_type non_treatment_test, mis	
	tab hyp_type hyp_nodiff, mis
	tab hyp_type hyp_t, mis
	tab hyp_type hyp_ks, mis
	
	
* number of outcome categories
	tab num_categories
	gen outcome_categories = num_categories
	replace outcome_categories="8" if outcome_categories==".i"
	destring outcome_categories, replace
	recode outcome_categories (8/9999999=8)
	lab def outcat 8 "continuous"
	lab val outcome_categories outcat
	tab outcome_categories
	lab var outcome_categories "DV categories"
	
	recode outcome_categories (2/7=0) (8=1), gen(outcome_continuous) 
	tab outcome_continuous
	lab var outcome_continuous "DV is continuous"
	
	recode outcome_categories (2=1 "DV Binary") (3/7=2 "DV 3-7 categories") (8=3 "DV Continuous"), gen(dvcategories)
	
	
* number of measures used to construct the outcome	
	tab num_measures
	lab var num_measures "No. of outcome measures"
	recode num_measures (1=0 "Single measure") (2/50=1 "Multiple measures"), gen(outcome_multimeasure)
	tab outcome_multimeasure
	lab var outcome_multimeasure "Outcome measured using >1 indicator"
	
	recode num_measures (1/2=0 "DV 1-2 items") (3/50=1 "3+ items"), gen(outcome_2vsmore)
	tab outcome_2vsmore	
	lab var outcome_2vsmore "DV: 3+ measures used"
	
	
* non-bonferonni corrected result of the hypothesis (hypothesis supported a 5% sig)	
	gen hyp_true_nomtc=hyp_true
	replace hyp_true_nomtc=1 if hyp_true_nomtc==0 & pvalue<0.05 & wrongsign!=1
	tab hyp_true_nomtc
	lab var hyp_true_nomtc "Hyp supported w/o multiple testing correction"

	
* bonferroni correction
	recode bonf ///
	(1=1 "No Bonferroni correction") ///
	(2=2 "Bonferroni factor 2") ///
	(3/20=3 "Bonferroni factor >2"), ///
	gen(bonfcat)	
	label var bonfcat "Boneferroni correction"

* STUDY-LEVEL VARIABLES	

* at least one hypothesis was supported in the study
	egen hyp_anytrue_nomtc=max(hyp_true_nomtc), by(vendor_id)
	tab hyp_anytrue_nomtc if hyp_num==1
	lab var hyp_anytrue_nomtc "At least 1 hypothesis supported|no multiple test corr"	
	tab hyp_anytrue_nomtc
	


********************************************************************************
* successful experiments excluding no-diff & non-exp hypotheses

* create insample flag
	cap drop insample
	gen insample=1
	replace insample=0 if hyp_nodiff==1|non_treatment_test==1
	lab var insample "excluding no-difference and non-experimental tests"
	tab insample // excluded 82 tests
	
	* how many studies left in sample?
	cap drop temp
	egen temp=max(insample), by(vendor_id)
	sum temp if hyp_num==1
	drop temp
	// 100 studies have at least one insample hypothesis
	
* total hyp	insample
	* total hypotheses
	cap drop total_hyp_insample
	egen total_hyp_insample = sum(insample), by(vendor_id)	
		tab total_hyp_insample // total hyp excluding no diff
		list study total_hyp_insample total_hyp insample hyp_nodiff non_treatment_test if _n<=100
		
* at least one hypothesis was supported in the study
	* true hypotheses insample
	gen hyp_true_insample= hyp_true if insample==1

	egen hyp_anytrue_insample=max(hyp_true_insample), by(vendor_id)
	tab hyp_anytrue_insample if hyp_num==1
	lab var hyp_anytrue_insample "At least 1 hypothesis supported"
	
	sort vendor_id
	br vendor_id PI if hyp_num==1 & hyp_anytrue_insample==1
	br vendor_id PI if hyp_num==1 & hyp_anytrue_insample==0


* at least 10% of hypotheses supported 
	// total hypotheses supported 
	egen total_hyp_true_insample=sum(hyp_true_insample), by(vendor_id)
	// what is 10% of total hypotheses
	gen temp=total_hyp_insample*0.1
	gen hyp_10pct_supp_insample=1 if total_hyp_true_insample>=temp & total_hyp_true_insample!=.
	replace hyp_10pct_supp_insample=0 if total_hyp_true_insample<temp & temp!=.
	drop temp
	sum hyp_10pct_supp_insample
	lab var hyp_10pct_supp_insample "At least 10% hypotheses supported"	
	
* successful experiment (at least 1 hyp true if #hyp<=10; or 10% hyp true if #hyp>10)	
	gen successfulexp_insample=hyp_anytrue_insample if total_hyp_insample<=10
	replace successfulexp_insample=hyp_10pct_supp_insample if total_hyp_insample>10
	tab successfulexp_insample if hyp_num==1
	tab successfulexp if hyp_num==1	
	tab successfulexp_insample successfulexp if hyp_num==1
	lab var successfulexp_insample "Successful study"	
	
	list study hyp_num total_hyp total_hyp_insample hyp_anytrue_insample hyp_true insample if successfulexp!=successfulexp_insample & insample==1

* % hypotheses supported
	gen hyp_pct_supported= total_hyp_true/total_hyp*100
	sum hyp_pct_supported
	lab var hyp_pct_supported "% of study's hypotheses supported"
	
	gen hyp_pct_supp_insample= total_hyp_true_insample/total_hyp_insample*100
	sum hyp_pct_supp_insample
	lab var hyp_pct_supp_insample "% of study's hypotheses supported"

********************************************************************************	
* create categorical variables for analysis

	recode samplesize ///
	(1/1000=1 "N<1001") (1001/2000=2 "N 1001-2000") (2001/3000=3 "N 2001-3000") (3001/10000=4 "N>3000"), ///
	gen(samplesizecat)
	tab samplesizecat
	lab var samplesizecat "Sample size"

	recode N_person ///
	(1/1000=1 "N<1001") (1001/2000=2 "N 1001-2000") (2001/3000=3 "N 2001-3000") (3001/10000=4 "N>3000"), ///
	gen(Npersoncat)
	tab Npersoncat	
	lab var Npersoncat "Sample size"
	
	recode medtime15 ///
	(0/2=1 "Up to 2m") (2.001/5=2 "2-5m") (5.001/10=3 "5-10m") (10.001/75=4 "Over 10m"), ///
	gen(medtimecat)
	tab medtimecat
	lab var medtimecat "Median duration"
	
********************************************************************************
* check if hypotheses are correctly specified as supported based on bonferroni correction
	
	gen criticalval=0.05
	replace criticalval=0.05/numoutcomes
	lab var criticalval "Bonferroni adj. critical value"
	
	cap drop hyp_true_check
	gen hyp_true_check=.
	replace hyp_true_check=1 if twop<criticalval & hyp_nodiff!=1 & rightdir!="no"
	replace hyp_true_check=1 if twop>criticalval & hyp_nodiff==1 & rightdir!="no"
	
	replace hyp_true_check=0 if twop>=criticalval& hyp_nodiff!=1
	replace hyp_true_check=0 if twop<criticalval& hyp_nodiff==1
	replace hyp_true_check=0 if rightdir=="no"
	
	tab hyp_true_check hyp_true, mis
	br proposal_id PI hyp_num hyp_true pvalue twop criticalval hyp_nodiff rightdir if hyp_true_check==0 & hyp_true==1
	 
	replace hyp_true=0 if hyp_true==1 & hyp_nodiff!=1 & pvalue>criticalval & pvalue!=. 
	// 1 change made
	
	br proposal_id PI hyp_num hyp_true pvalue twop hyp_nodiff if hyp_true_check==1 & hyp_true==0
	
	lab var hyp_true_check "Cross-checked decision"
	
* create critical N for bonferroni-corrected p-values
	gen crit_N_bonf = crit_N
	replace crit_N_bonf= N_person * [se / (abs(dif) / invnorm(criticalval/2))]^2 if bonf>1

	sum crit_N_bonf	
	
	
sa "../Metadata/tess_analysisdata.dta", replace
